package com.qdlc.p2p.biz.task;

import com.qdlc.p2p.dal.dto.Borrow;
import com.qdlc.p2p.dal.dto.BorrowRepayment;
import com.qdlc.p2p.dal.model.BorrowModel;

public class QueueUtil {

    /**
     * 投标
     * @param model
     * @param borrow
     * @throws Exception
     */
    
    public static void tender(BorrowModel model,Borrow borrow)throws Exception{
        ValueEvent event = new ValueEvent();        
        event.setOperate("tender");
        event.setBorrowModel(model);
        event.setBorrow(borrow);
        JobQueue.getTenderInstance().offer(event);

    }
        
    
    /**
     * 自动投标
     * @param model
     * @throws Exception
     */
    public static void autoTender(BorrowModel model) throws Exception {
        ValueEvent event = new ValueEvent();
        event.setOperate("autoTender");
        event.setBorrowModel(model);
        JobQueue.getTenderInstance().offer(event);
    }
    
    /**
     * 满标复审
     * @param model
     * @throws Exception
     */
    public static void autoVerifyFull(BorrowModel model) throws Exception {
        ValueEvent event = new ValueEvent();
        event.setOperate("autoVerifyFull");
        event.setBorrowModel(model);
        JobQueue.getVerifyBorrowInstance().offer(event);
    }   

    /**
     * 复审通过
     * @param model
     * @throws Exception
     */
    public static void autoVerifyFullSuccess(BorrowModel model) throws Exception {
        ValueEvent event = new ValueEvent();
        event.setOperate("autoVerifyFullSuccess");
        event.setBorrowModel(model);
        JobQueue.getVerifyBorrowInstance().offer(event);
    }

    /**
     * 复审不通过
     * @param model
     * @throws Exception
     */
    public static void autoVerifyFullFail(BorrowModel model) throws Exception {
        ValueEvent event = new ValueEvent();
        event.setOperate("autoVerifyFullFail");
        event.setBorrowModel(model);
        JobQueue.getVerifyBorrowInstance().offer(event);
    }

    /**
     * 还款
     * @param borrowRepayment
     */
    public static void repay(BorrowRepayment borrowRepayment) {
        ValueEvent event = new ValueEvent();
        event.setOperate("repay");
        event.setBorrowRepayment(borrowRepayment);
        JobQueue.getBorrowInstance().offer(event);
    }
    /**
     * 撤标
     * @param model
     */
    public static void autoCancel(Borrow borrow) {
        ValueEvent event = new ValueEvent();
        event.setOperate("autoCancel");
        event.setBorrow(borrow);
        JobQueue.getBorrowInstance().offer(event);
    }
    
    /**
     * 提前还款
     * @param borrowRepayment
     */
    public static void doPriorRepay(BorrowRepayment borrowRepayment) {
        ValueEvent event = new ValueEvent();
        event.setOperate("doPriorRepay");
        event.setBorrowRepayment(borrowRepayment);
        JobQueue.getBorrowInstance().offer(event);
    }
    /**
     * 后台逾期垫付
     * @param borrowRepayment
     */
    public static void overdue(BorrowRepayment borrowRepayment) {
        ValueEvent event = new ValueEvent();
        event.setOperate("overdue");
        event.setBorrowRepayment(borrowRepayment);
        JobQueue.getBorrowInstance().offer(event);
    }
    /**
     * 前台逾期垫付
     * @param borrowRepayment
     */
    public static void overduePayment(BorrowRepayment borrowRepayment) {
        ValueEvent event = new ValueEvent();
        event.setOperate("overduePayment");
        event.setBorrowRepayment(borrowRepayment);
        JobQueue.getBorrowInstance().offer(event);
    }
    
    /**
     * 发标回调
     * @param user
     * @param ips
     */
    public static void doAddBorrow(BorrowModel bm){
        ValueEvent event = new ValueEvent();
        event.setOperate("doAddBorrow");
        event.setBorrowModel(bm);
        JobQueue.getBorrowInstance().offer(event);
        
    }
    /**
     * 登记担保方
     * @param bm
     */
    public static void doIpsRegisterGuarantor(BorrowModel bm, String resultFlag){
        ValueEvent event = new ValueEvent();
        event.setOperate("doIpsRegisterGuarantor");
        event.setBorrowModel(bm);
        event.setResultFlag(resultFlag);
        JobQueue.getUserInstance().offer(event);
    }
    
    /**
     * 投标回调
     * @param bm
     */
    public static void doAddTender(BorrowModel bm,String resultFlag){
        ValueEvent event = new ValueEvent();
        event.setOperate("doAddTender");
        event.setBorrowModel(bm);
        event.setResultFlag(resultFlag);
        JobQueue.getTenderInstance().offer(event);
        
    }
    
    /**
     * 代偿回调
     * @param borrowRepayment
     */
    public static void doCompensateSuccess(BorrowRepayment borrowRepayment) {
        ValueEvent event = new ValueEvent();
        event.setOperate("doCompensateSuccess");
        event.setBorrowRepayment(borrowRepayment);
        JobQueue.getBorrowInstance().offer(event);
    }
}
